package com.dorm.cj;

import java.lang.reflect.Proxy;

public class TestProxy<T> {

    public T getInstance(T target) {

        Object o = Proxy.newProxyInstance(target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),
                (proxy, method, args) -> {
                    System.out.println("proxy======");
                    System.out.println(proxy.toString());
                    return method.invoke(target, args);
                });
        return (T) o;
    }
}
